#include "GameObject.h"
#include "Defines.h"
#include "manager.h"
#include "Application.h"
#include "AApplication.h"
#include <math.h>
#include <iostream>

#ifdef _LOGIC_DEBUG
long int g_liObjects=0;
#endif
bool BonusClock = false;

//USEFUL FUNCTIONS FOR ANGLES
float COS (float angle)
{
	if (angle == MOVE_UP)
		return 1.0f;
	else if (angle == MOVE_LEFT)
		return 0.0f;
	else if (angle == MOVE_DOWN)
		return -1.0f;
	else if (angle == MOVE_RIGHT)
		return 0.0f;
	return cos(angle);
}

float SIN (float angle)
{
	if (angle == MOVE_UP)
		return 0.0f;
	else if (angle == MOVE_LEFT)
		return 1.0f;
	else if (angle == MOVE_DOWN)
		return 0.0f;
	else if (angle == MOVE_RIGHT)
		return -1.0f;
	return sin(angle);
}

float ROT_RIGHT (float angle)
{
	if (angle == MOVE_UP)
		return MOVE_RIGHT;
	else if (angle == MOVE_LEFT)
		return MOVE_UP;
	else if (angle == MOVE_DOWN)
		return MOVE_LEFT;
	else if (angle == MOVE_RIGHT)
		return MOVE_DOWN;
	return angle-3.141592f/2.0f;
}

float ROT_LEFT (float angle)
{
	if (angle == MOVE_UP)
		return MOVE_LEFT;
	else if (angle == MOVE_LEFT)
		return MOVE_DOWN;
	else if (angle == MOVE_DOWN)
		return MOVE_RIGHT;
	else if (angle == MOVE_RIGHT)
		return MOVE_UP;
	return angle+3.141592f/2.0f;
}

float ROT_BACK (float angle)
{
	if (angle == MOVE_UP)
		return MOVE_DOWN;
	else if (angle == MOVE_LEFT)
		return MOVE_RIGHT;
	else if (angle == MOVE_DOWN)
		return MOVE_UP;
	else if (angle == MOVE_RIGHT)
		return MOVE_LEFT;
	return angle+3.141592f;
}

GameObject::GameObject()
{
	SPEED_TEST;

#ifdef _LOGIC_DEBUG
	g_liObjects++;
#endif
	iHP=0;
	pParent=0;
	uiID=0;
	uiGroupID=0;
	Size.X = 1.0f;
	Size.Y = 1.0f;
	Size.Z = 1.0f;
}

GameObject::GameObject(unsigned int id, unsigned int gid, Pool* p, float x, float y)
{
	SPEED_TEST;

#ifdef _LOGIC_DEBUG
	g_liObjects++;
#endif
	uiID = id;
	uiGroupID = gid;
	pParent = p;
	Pos.X = x;
	Pos.Y = y;
}

GameObject::~GameObject()
{
	SPEED_TEST;

#ifdef _LOGIC_DEBUG
	g_liObjects--;
#endif
}

void GameObject::Explode()
{
	pParent->mgr->AddExplosion(Pos.X, Pos.Y);
}

Timers& GameObject::Timer()
{
	SPEED_TEST;

	return pParent->mgr->App->TimerSystem;
}

APanzer::APanzer()
{
	SPEED_TEST;

	TimerMove_IsMove = false;
	TimerMove_IsStopped = false;
	Speed = 0;
	TimerShoot_IsReloading = false;
	TimerShoot_ReloadingTime = 0;			//reloading the gun takes uiShootCD msec
	TimerMove_LeftTime = 0;
}

APanzer::APanzer(unsigned int id, unsigned int gid, Pool* p, float x, float y, float dir, unsigned int type):GameObject(id, gid, p, x, y)
{
	SPEED_TEST;

	TimerMove_IsMove = false;
	TimerMove_IsStopped = false;
	TimerMove_LeftTime = 0;
	Speed = 0;
	TimerShoot_IsReloading = false;
	TimerShoot_ReloadingTime = 0;			//reloading the gun takes uiShootCD msec
	TimerShoot_LeftTime = 0;
	uiType = type;
	Rot.Z = dir;
};

APanzer::~APanzer()
{
	SPEED_TEST;
}

void APanzer::Shoot()
{
	SPEED_TEST;

	if (TimerShoot_IsReloading) return;
	TimerShoot_IsReloading = true;
	TimerShoot_LeftTime = TimerShoot_ReloadingTime;
	Msg message;
	message.uiIdObject=uiID;
	message.uiIdPool=pParent->GetID();
	message.uiEvent=MSG_CREATE;
	message.x = Pos.X + COS(Rot.Z)*Size.X/2;
	message.y = Pos.Y + SIN(Rot.Z)*Size.Y/2;
	message.direct = Rot.Z;
	if (uiGroupID==GID_USERPANZER)
		message.uiObjectType=GID_USERBULLET;
	else
		message.uiObjectType=GID_AIBULLET;
	pParent->mgr->Message(&message);
}

AIPanzer::AIPanzer()
{
	SPEED_TEST;
}

AIPanzer::AIPanzer(unsigned int id, unsigned int gid, Pool* p, float x, float y, float dir, unsigned int type):APanzer(id, gid, p, x, y, dir, type)
{
	SPEED_TEST;
	Speed = 0.000003f;
	TimerShoot_ReloadingTime = 1500000;
	TimerThinking_IsThinking = false;
	TimerThinking_LeftTime = 0;
	Load("./media/graphics/mainpanzer");
	Color.X=1.0f;
	Color.Y=1.0f;
	Color.Z=1.0f;
}

AIPanzer::~AIPanzer()
{
	SPEED_TEST;
}

void AIPanzer::TryToMove(int shoot, int forw, int back, int right, int left)
{
	if (!TimerThinking_IsThinking && !TimerMove_IsMove && !TimerMove_IsStopped)
	{
		int chance = rand()%(shoot+forw+back+right+left);
		left+=right+=back+=forw+=shoot;
		if (chance < shoot)
			Shoot();
		else
		{
			if (chance >= shoot && chance < forw)
				;
			else if (chance >= forw && chance < back)
				Rot.Z = ROT_BACK(Rot.Z);
			else if (chance >= back && chance < right)
				Rot.Z = ROT_RIGHT(Rot.Z);
			else if (chance >= right && chance < left)
				Rot.Z = ROT_LEFT(Rot.Z);
			TimerMove_IsMove = true;
			TimerMove_IsStopped = false;
			Depature.X = Pos.X;
			Depature.Y = Pos.Y;
			Destination.X = Pos.X + COS(Rot.Z);
			Destination.Y = Pos.Y + SIN(Rot.Z);
		}
	}
	else if (TimerMove_IsMove && TimerMove_IsStopped)
	{
		int chance = rand()%(shoot+forw+back);
		back+=forw+=shoot;
		if (chance < shoot)
			Shoot();
		else
		{
			if (chance >= shoot && chance < forw)
				;
			else if (chance >= forw && chance < back)
			{
				float x,y;
				Rot.Z = ROT_BACK(Rot.Z);
				x = Depature.X;
				y = Depature.Y;
				Depature.X = Destination.X;
				Depature.Y = Destination.Y;
				Destination.X = x;
				Destination.Y = y;
			}
			TimerMove_IsMove = true;
			TimerMove_IsStopped = false;
		}
	}
}

void AIPanzer::Message (Msg *message)
{
	SPEED_TEST;

	Msg answer;
	switch (message->uiEvent)
	{
	case MSG_MOVE:
		Pos.X = message->dx;
		Pos.Y = message->dy;
	break;
	case MSG_UPDATE:
	{
		unsigned int updating_time = message->uiTime;
		if (TimerShoot_IsReloading)
		{
			if (TimerShoot_LeftTime > updating_time)
				TimerShoot_LeftTime -=updating_time;
			else
			{
				TimerShoot_LeftTime = 0;
				TimerShoot_IsReloading = false;
			}
		}
		updating_time = message->uiTime + TimerMove_LeftTime;
		if (TimerMove_IsMove && !TimerMove_IsStopped)
		{
			answer.dx=Pos.X;
			answer.dy=Pos.Y;
			while (updating_time >= UPDATE_TIME)
			{
				updating_time -= UPDATE_TIME;
				if (fabsf(Destination.X - answer.dx) + fabsf(Destination.Y - answer.dy) <= Speed*UPDATE_TIME)
				{
					answer.dx = Destination.X;
					answer.dy = Destination.Y;
					updating_time = 0;
					TimerMove_IsMove = false;
				}
				else
				{
					answer.dx+=Speed*cos(Rot.Z)*UPDATE_TIME;
					answer.dy+=Speed*sin(Rot.Z)*UPDATE_TIME;
					if (rand()%100 < 5) Shoot();
				}
			}
			if (answer.dx != Pos.X || answer.dy != Pos.Y)
			{
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_MOVE;
				pParent->mgr->Message(&answer);
			}
			TimerMove_LeftTime = updating_time;
		}
		// THINKING SYSTEM (that wouldn't make them clever, they would just have short waitings after collisions)
		/*updating_time = message->uiTime + TimerThinking_LeftTime;
		if (TimerThinking_IsThinking)
		{
			while (updating_time >= UPDATE_TIME)
			{
				updating_time-=UPDATE_TIME;
				TimerThinking_ThinkingTime-=UPDATE_TIME;
				if (TimerThinking_ThinkingTime<=UPDATE_TIME)
				{
					TimerThinking_IsThinking = false;
					updating_time = 0;
				}
			}
			TimerThinking_LeftTime = updating_time;
		}*/
		if (TimerMove_IsMove && TimerMove_IsStopped)
			TryToMove(1, 1, 1, 0, 0);
		if (!TimerMove_IsMove)
			TryToMove(1,2,1,1,1);
	}
	break;
	case MSG_COLLISION:
		if (!Renderable)
		{
			answer.uiIdObject=uiID;
			answer.uiIdPool=pParent->GetID();
			answer.uiEvent=MSG_DEATH;

			pParent->mgr->Message(&answer);
			Explode();
		}
		if (message->Border || message->Water)
		{
			TimerMove_IsMove = false;
			TimerMove_IsStopped = false;
			TimerThinking_IsThinking = false;
			break;
		}
		switch (pParent->mgr->GetObjectByID(message->uiIdObject)->uiGroupID)
		{
		case GID_USERBULLET:
			iHP -= pParent->mgr->GetObjectByID(message->uiIdObject)->iHP;
			if (Colored)		//if colored panzer is attacked, bonus will be created
			{
				Colored=false;
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_CREATE;
				Point2D new_bonus;
				//new_bonus = pParent->mgr->GetFreePlace();
				answer.x = new_bonus.X;
				answer.y = new_bonus.Y;
				answer.direct = 0;
				pParent->mgr->Message(&answer);
			}
			if (iHP<=0)
			{
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_DEATH;
				pParent->mgr->Message(&answer);
				Explode();
			}
		break;
		case GID_AIBULLET:
			if (message->Reason)
			{
				Pos.X = message->dx;
				Pos.Y = message->dy;
				if (Pos.X == Destination.X && Pos.Y == Destination.Y)
				TimerMove_IsMove = false;
			}
		break;
		case GID_STAFF:
			TimerMove_IsMove = false;
			TimerMove_IsStopped = false;
			TryToMove(5, 0, 1, 2, 2);
		break;
		case GID_AIPANZER:
			if (message->Reason && TimerMove_IsMove && !TimerMove_IsStopped)
			{
				if (Pos.X == Depature.X && Pos.Y == Depature.Y)
				{
					TimerMove_IsMove = false;
					TimerMove_IsStopped = false;
				}
				else
					TimerMove_IsStopped = true;
			}
			TryToMove(0, 1, 4, 4, 4);
		break;
		case GID_USERPANZER:
			if (message->Reason && TimerMove_IsMove && !TimerMove_IsStopped)
			{
				if (Pos.X == Depature.X && Pos.Y == Depature.Y)
				{
					TimerMove_IsMove = false;
					TimerMove_IsStopped = false;
				}
				else
					TimerMove_IsStopped = true;
			}
		break;
		case GID_WALL:
			TimerMove_IsMove = false;
			TimerMove_IsStopped = false;
			TryToMove(2, 1, 3, 3, 3);
		break;
		}
	break;
	case MSG_DEATH:
	break;
	}
}

PPanzer::PPanzer(unsigned int id, unsigned int gid, Pool* p, float x, float y, float dir, unsigned int type):APanzer(id, gid, p, x, y, dir, type)
{
	SPEED_TEST;

	Load("./media/graphics/mainpanzer");
	Color.X=0.5f;
	Color.Y=1.0f;
	Color.Z=0.5f;
	Speed = 0.000005f;
	TimerShoot_IsReloading = TimerMove_IsMove = TimerMove_IsStopped = false;
	TimerShoot_ReloadingTime = 1500000;
	TimerShoot_LeftTime = 0;
	TimerMove_LeftTime = 0;
	Depature.X = Pos.X;
	Depature.Y = Pos.Y;
}

PPanzer::~PPanzer()
{
	SPEED_TEST;
}

void PPanzer::Message (Msg *message)
{
	SPEED_TEST;

	Msg answer;
	float x, y;
	switch (message->uiEvent)
	{
	case MSG_KB:
		if (message->fKeyPressed)
			switch (message->Code)
			{
			case VK_RIGHT:
				if (TimerMove_IsMove && !TimerMove_IsStopped) break;
				if (TimerMove_IsMove && TimerMove_IsStopped && (Rot.Z==MOVE_UP || Rot.Z==MOVE_DOWN)) break;
				TimerMove_IsMove = true;
				TimerMove_IsStopped = false;
				if (TimerMove_IsStopped)
				{
					if (Rot.Z==MOVE_LEFT)
					{
						Rot.Z=MOVE_RIGHT;
						x = Destination.X;
						y = Destination.Y;
						Destination.X = Depature.X;
						Destination.Y = Depature.Y;
						Depature.X = x;
						Depature.Y = y;
					}
					break;
				}
				Rot.Z=MOVE_RIGHT;
				Depature.X = Pos.X;
				Depature.Y = Pos.Y;
				Destination.X = Pos.X + COS(Rot.Z);
				Destination.Y = Pos.Y + SIN(Rot.Z);
				break;
			case VK_UP:
				if (TimerMove_IsMove && !TimerMove_IsStopped) break;
				if (TimerMove_IsMove && TimerMove_IsStopped && (Rot.Z==MOVE_LEFT || Rot.Z==MOVE_RIGHT)) break;
				TimerMove_IsMove = true;
				TimerMove_IsStopped = false;
				if (TimerMove_IsStopped)
				{
					if (Rot.Z==MOVE_DOWN)
					{
						Rot.Z=MOVE_UP;
						x = Destination.X;
						y = Destination.Y;
						Destination.X = Depature.X;
						Destination.Y = Depature.Y;
						Depature.X = x;
						Depature.Y = y;
					}
					break;
				}
				Rot.Z=MOVE_UP;
				Depature.X = Pos.X;
				Depature.Y = Pos.Y;
				Destination.X = Pos.X + COS(Rot.Z);
				Destination.Y = Pos.Y + SIN(Rot.Z);
				break;
			case VK_LEFT:
				if (TimerMove_IsMove && !TimerMove_IsStopped) break;
				if (TimerMove_IsMove && TimerMove_IsStopped && (Rot.Z==MOVE_UP || Rot.Z==MOVE_DOWN)) break;
				TimerMove_IsMove = true;
				TimerMove_IsStopped = false;
				if (TimerMove_IsStopped)
				{
					if (Rot.Z==MOVE_RIGHT)
					{
						Rot.Z=MOVE_LEFT;
						x = Destination.X;
						y = Destination.Y;
						Destination.X = Depature.X;
						Destination.Y = Depature.Y;
						Depature.X = x;
						Depature.Y = y;
					}
					break;
				}
				Rot.Z=MOVE_LEFT;
				Depature.X = Pos.X;
				Depature.Y = Pos.Y;
				Destination.X = Pos.X + COS(Rot.Z);
				Destination.Y = Pos.Y + SIN(Rot.Z);
				break;
			case VK_DOWN:
				if (TimerMove_IsMove && !TimerMove_IsStopped) break;;
				if (TimerMove_IsMove && TimerMove_IsStopped && (Rot.Z==MOVE_LEFT || Rot.Z==MOVE_RIGHT)) break;
				TimerMove_IsMove = true;
				TimerMove_IsStopped = false;
				if (TimerMove_IsStopped)
				{
					if (Rot.Z==MOVE_UP)
					{
						Rot.Z=MOVE_DOWN;
						x = Destination.X;
						y = Destination.Y;
						Destination.X = Depature.X;
						Destination.Y = Depature.Y;
						Depature.X = x;
						Depature.Y = y;
					}
					break;
				}
				Rot.Z=MOVE_DOWN;
				Depature.X = Pos.X;
				Depature.Y = Pos.Y;
				Destination.X = Pos.X + COS(Rot.Z);
				Destination.Y = Pos.Y + SIN(Rot.Z);
				break;
			case VK_SPACE:
				Shoot();
				break;
			}
		break;
	case MSG_MOVE:
		Pos.X = message->dx;
		Pos.Y = message->dy;
		if (Pos.X == Destination.X && Pos.Y == Destination.Y)
			TimerMove_IsMove = false;
		break;
	case MSG_UPDATE:
		{
			unsigned int updating_time = message->uiTime;
			if (TimerShoot_IsReloading)
				if (TimerShoot_LeftTime > updating_time)
					TimerShoot_LeftTime -=updating_time;
				else
				{
					TimerShoot_LeftTime = 0;
					TimerShoot_IsReloading = false;
				}
			updating_time = message->uiTime + TimerMove_LeftTime;
			if (TimerMove_IsMove && !TimerMove_IsStopped)
			{
				answer.dx=Pos.X;
				answer.dy=Pos.Y;
				while (updating_time >= UPDATE_TIME)
				{
					updating_time -= UPDATE_TIME;
					if (fabsf(Destination.X - answer.dx) + fabsf(Destination.Y - answer.dy) <= Speed*UPDATE_TIME)
					{
						answer.dx = Destination.X;
						answer.dy = Destination.Y;
						updating_time = 0;
					}
					else
					{
						answer.dx+=Speed*COS(Rot.Z)*UPDATE_TIME;
						answer.dy+=Speed*SIN(Rot.Z)*UPDATE_TIME;
					}
				}
				if (answer.dx != Pos.X || answer.dy != Pos.Y)
				{
					answer.uiIdObject=uiID;
					answer.uiIdPool=pParent->GetID();
					answer.uiEvent=MSG_MOVE;
					pParent->mgr->Message(&answer);
				}
				TimerMove_LeftTime = updating_time;
			}
		}
		break;
	case MSG_COLLISION:
		if (message->Border || message->Water)
		{
			TimerMove_IsMove = false;
			TimerMove_IsStopped = false;
			break;
		}
		switch (pParent->mgr->GetObjectByID(message->uiIdObject)->uiGroupID)
		{
		case GID_USERBULLET:
			if (message->Reason)
			{
				Pos.X = message->dx;
				Pos.Y = message->dy;
				if (Pos.X == Destination.X && Pos.Y == Destination.Y)
				TimerMove_IsMove = false;
			}
			break;
		case GID_AIBULLET:
			iHP -= pParent->mgr->GetObjectByID(message->uiIdObject)->iHP;
			if (iHP<=0)
			{
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_DEATH;
				pParent->mgr->Message(&answer);
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_CHNGLVL;
				answer.fWin = false;
				pParent->mgr->Message(&answer);
				Explode();
			}
			break;
		case GID_AIPANZER:
			if (message->Reason && TimerMove_IsMove && !TimerMove_IsStopped)
			{
				if (Pos.X == Depature.X && Pos.Y == Depature.Y)
				{
					TimerMove_IsMove = false;
					TimerMove_IsStopped = false;
				}
				else
					TimerMove_IsStopped = true;
			}
			break;
		case GID_WALL:
			TimerMove_IsMove = false;
			TimerMove_IsStopped = false;
			break;
		case B_TYPE_STAR:
			Upgrade();
			break;
		case B_TYPE_GUN:
			Upgrade();
			Upgrade();
			Upgrade();
			break;
		case B_TYPE_PANZER:
			// !!!!!!!!
			break;
		case B_TYPE_HELMET:
			// !!!!!!!!
			break;
		}
		break;
	}
}

void PPanzer::Upgrade()
{
	SPEED_TEST;
}

Bullet::Bullet(unsigned int id, unsigned int gid, Pool* p, float x, float y, float dir, unsigned int panzerid):GameObject(id, gid, p, x, y)
{
	SPEED_TEST;

	Load("./media/graphics/maverick");
	Color.X = 0.7f;
	Color.Y = 0.7f;
	Color.Z = 0.0f;
	Size.X = 1.0f;
	Size.Y = 1.0f;
	Size.Z = 1.0f;
	Rot.Z = dir;
	uiPanzerID = panzerid;
	Speed = 0.000006f;
	TimerMove_LeftTime=0;
	if (pParent->mgr->GetObjectByID(panzerid)->uiGroupID == GID_USERPANZER)
		uiGroupID = GID_USERBULLET;
	else
		uiGroupID = GID_AIBULLET;
}

Bullet::~Bullet()
{
	SPEED_TEST;
}

void Bullet::Message(Msg *message)
{
	SPEED_TEST;

	Msg answer;
	switch (message->uiEvent)
	{
	case MSG_COLLISION:
		if (message->Border)
		{
			answer.uiIdObject=uiID;
			answer.uiIdPool=pParent->GetID();
			answer.uiEvent=MSG_DEATH;
			pParent->mgr->Message(&answer);
			Explode();
			break;
		}
		if(message->Water) break;
		switch (pParent->mgr->GetObjectByID(message->uiIdObject)->uiGroupID)
		{
		case GID_USERPANZER:
			if (uiGroupID==GID_USERBULLET)
				break;
			else
			{
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_DEATH;
				pParent->mgr->Message(&answer);
				Explode();
			}
			break;
		case GID_USERBULLET:
			if (uiGroupID==GID_USERBULLET)
				break;
			else
			{
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_DEATH;
				pParent->mgr->Message(&answer);
				Explode();
			}
			break;
		case GID_AIPANZER:
			if (uiGroupID==GID_AIBULLET)
				break;
			else
			{
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_DEATH;
				pParent->mgr->Message(&answer);
				Explode();
			}
			break;
		case GID_AIBULLET:
			if (uiGroupID==GID_AIBULLET)
				break;
			else
			{
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_DEATH;
				pParent->mgr->Message(&answer);
				Explode();
			}
			break;
		case GID_WALL:
		case GID_STAFF:
			answer.uiIdObject=uiID;
			answer.uiIdPool=pParent->GetID();
			answer.uiEvent=MSG_DEATH;
			pParent->mgr->Message(&answer);
			Explode();
			break;
		}
		break;
	case MSG_UPDATE:
		{
			unsigned int updating_time = message->uiTime + TimerMove_LeftTime;
			while (updating_time >= UPDATE_TIME)
			{
				Pos.X += Speed*cos(Rot.Z)*UPDATE_TIME;
				Pos.Y += Speed*sin(Rot.Z)*UPDATE_TIME;
				updating_time -= UPDATE_TIME;
			}
			TimerMove_LeftTime = updating_time;
			answer.uiIdObject=uiID;
			answer.uiIdPool=pParent->GetID();
			answer.uiEvent=MSG_MOVE;
			answer.dx=Pos.X;
			answer.dy=Pos.Y;
			pParent->mgr->Message(&answer);
		}
		break;
	}
}

Wall::Wall(unsigned int id, unsigned int gid, Pool* p, float x, float y, bool con):GameObject(id, gid, p, x, y)
{
	SPEED_TEST;

	Concrete = con;
	Color.X=1.0f;
	Color.Y=1.0f;
	Color.Z=1.0f;
	if (Concrete)
		Load("./media/graphics/concrete");
	else
		Load("./media/graphics/bricks");
}

Wall::~Wall()
{
	SPEED_TEST;
}

void Wall::Message (Msg *message)
{
	SPEED_TEST;

	Msg answer;
	switch (message->uiEvent)
	{
	case MSG_COLLISION:
		switch (pParent->mgr->GetObjectByID(message->uiIdObject)->uiGroupID)
		{
		case GID_USERBULLET:
		case GID_AIBULLET:
			if	(	((APanzer*)pParent->mgr->GetObjectByID(
					((Bullet*)pParent->mgr->GetObjectByID(message->uiIdObject))->uiPanzerID ))->uiType == P_TYPE_U_UP3 ||
					((APanzer*)pParent->mgr->GetObjectByID(
					((Bullet*)pParent->mgr->GetObjectByID(message->uiIdObject))->uiPanzerID ))->uiType == P_TYPE_AI_4 ||
					!Concrete	)
			{
				answer.uiIdObject=uiID;
				answer.uiIdPool=pParent->GetID();
				answer.uiEvent=MSG_DEATH;
				pParent->mgr->Message(&answer);
				Explode();
			}
		break;
		}
	break;
	}
}

Bonus::Bonus()
{
	SPEED_TEST;
}

Bonus::Bonus(unsigned int id, unsigned int gid, Pool* p, float x, float y):GameObject(id, gid, p, x, y)
{
	SPEED_TEST;
}

Bonus::~Bonus()
{
	SPEED_TEST;
}

void Bonus::Message (Msg *Message)
{
	SPEED_TEST;
}

Staff::Staff()
{
	SPEED_TEST;
}

Staff::Staff(unsigned int id, unsigned int gid, Pool* p, float x, float y):GameObject(id, gid, p, x, y)
{
	SPEED_TEST;

	Color.X=0.2f;
	Color.Y=0.2f;
	Color.Z=0.2f;
	Load("./media/graphics/sphere");
}

Staff::~Staff()
{
	SPEED_TEST;
}

void Staff::Message (Msg *message)
{
	SPEED_TEST;

	Msg answer;
	switch (message->uiEvent)
	{
	case MSG_COLLISION:
		switch (pParent->mgr->GetObjectByID(message->uiIdObject)->uiGroupID)
		{
		case GID_USERBULLET:
		case GID_AIBULLET:
			answer.uiIdObject=uiID;
			answer.uiIdPool=pParent->GetID();
			answer.uiEvent=MSG_DEATH;
			pParent->mgr->Message(&answer);
			Explode();
		break;
		}
	break;
	}
}